package com.datasecops.scannerservices.controller;

import com.datasecops.scannerservices.config.KafkaConfig;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 生产者控制类
 * @author: SunLingzhi
 * @time: 2022/7/29 14:40
 */
@RestController
public class ProducerController {

    //模板
    @Resource
    private KafkaTemplate<String,String> kafka;

    @RequestMapping(value = "sendMsg")
    public String data(String msg){
       // kafka.send(KafkaConfig.TOPIC_FIRST,msg);
        return "ok";
    }

    //分区
    @RequestMapping(value = "sendMsgPartitions")
    public String sendMsgPartitions(String msg){
        //kafka.send(KafkaConfig.TOPIC_INSTRUCT, KafkaConfig.PARTITIONS_START,"",msg);
        return "ok";
    }

    @RequestMapping(value = "sendMsgTest")
    public String sendMsgPartitionsTest(String msg){
        for (int i = 0; i <= 100; i++) {
            //kafka.send(KafkaConfig.TOPIC_SCAN_UPLOAD,"消息次序：" + i);
        }
        return "ok";
    }
}
